<?php
namespace Modules\Region\Library;

use Phalcon\Mvc\User\Plugin;
use Phalcon\Di;

class Region extends Plugin
{
    protected $_region;
    protected $_regionName;
    protected $_contentModel;
    public function __construct(string $regionName)
    {
        $di = $this->getDI();
        $region = $di->getShared('entityManager')->get('configList', ['id' => $regionName, 'contentModel' => 'region']);
        if($region){
            $this->_region = $region;
        }
        $this->_regionName = $regionName;
        $this->_contentModel = $this->entityManager->contentModel('block');
    }

    public function render(){
        $regionData = $this->entityManager->find('block', ['region' => $this->_regionName]);
        $blockContentModel = $this->entityManager->contentModel('block');
        foreach ($regionData as $block){

        }
    }

    public function getBlock($blockName){
        $blockName = $this->entityManager->get('block',['region' => $this->_regionName, 'block' => $blockName]);
    }
}